<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>nsDialogs</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
b
{
	color: red;
}
code
{
	margin-left: 20px;
	padding: 7px;
	background-color: rgb(240,240,240);
}
</style>
</head>
<body>

<h1>NSIS nsDialogs Plug-in</h1>
<p><i>Next generation of user interface design</i></p>

<h2>Table of Contents</h2>

<ul>
<li><a href="#intro">Introduction</a></li>
<li>
<a href="#step">Step-by-Step Tutorial</a>
<ul>
<li><a href="#step-basic">Basic Script</a></li>
<li><a href="#step-page">Custom Page</a></li>
<li><a href="#step-create">Creating Page</a></li>
<li><a href="#step-show">Showing Page</a></li>
<li><a href="#step-add">Adding Controls</a></li>
<li><a href="#step-state">Control State</a></li>
<li><a href="#step-notify">Real-time Notification</a></li>
<li><a href="#step-memory">Memory</a></li>
</ul>
</li>
<li>
<a href="#ref">Function Reference</a>
<ul>
<li><a href="#ref-create">Create</a></li>
<li><a href="#ref-createcontrol">CreateControl</a></li>
<li><a href="#ref-show">Show</a></li>
<li><a href="#ref-selectfiledialog">SelectFileDialog</a></li>
<li><a href="#ref-selectfolderdialog">SelectFolderDialog</a></li>
<li><a href="#ref-setrtl">SetRTL</a></li>
<li><a href="#ref-getuserdata">GetUserData</a></li>
<li><a href="#ref-setuserdata">SetUserData</a></li>
<li><a href="#ref-onback">OnBack</a></li>
<li><a href="#ref-onchange">OnChange</a></li>
<li><a href="#ref-onclick">OnClick</a></li>
<li><a href="#ref-onnotify">OnNotify</a></li>
<li><a href="#ref-createtimer">CreateTimer</a></li>
<li><a href="#ref-killtimer">KillTimer</a></li>
</ul>
</li>
<li>
<a href="#mref">Macro Reference</a>
<ul>
<li><a href="#mref-create">NSD_Create*</a></li>
<li><a href="#mref-onback">NSD_OnBack</a></li>
<li><a href="#mref-onchange">NSD_OnChange</a></li>
<li><a href="#mref-onclick">NSD_OnClick</a></li>
<li><a href="#mref-onnotify">NSD_OnNotify</a></li>
<li><a href="#mref-createtimer">NSD_CreateTimer</a></li>
<li><a href="#mref-killtimer">NSD_KillTimer</a></li>
<li><a href="#mref-addstyle">NSD_AddStyle</a></li>
<li><a href="#mref-addexstyle">NSD_AddExStyle</a></li>
<li><a href="#mref-gettext">NSD_GetText</a></li>
<li><a href="#mref-settext">NSD_SetText</a></li>
<li><a href="#mref-settextlimit">NSD_SetTextLimit</a></li>
<li><a href="#mref-getstate">NSD_GetState</a></li>
<li><a href="#mref-setstate">NSD_SetState</a></li>
<li><a href="#mref-check">NSD_Check</a></li>
<li><a href="#mref-uncheck">NSD_Uncheck</a></li>
<li><a href="#mref-cbaddstring">NSD_CB_AddString</a></li>
<li><a href="#mref-cbselectstring">NSD_CB_SelectString</a></li>
<li><a href="#mref-lbaddstring">NSD_LB_AddString</a></li>
<li><a href="#mref-lbdelstring">NSD_LB_DelString</a></li>
<li><a href="#mref-lbclear">NSD_LB_Clear</a></li>
<li><a href="#mref-lbgetcount">NSD_LB_GetCount</a></li>
<li><a href="#mref-lbselectstring">NSD_LB_SelectString</a></li>
<li><a href="#mref-lbgetselection">NSD_LB_GetSelection</a></li>
<li><a href="#mref-setfocus">NSD_SetFocus</a></li>
<li><a href="#mref-setimage">NSD_SetImage</a></li>
<li><a href="#mref-setsimage">NSD_SetStretchedImage</a></li>
<li><a href="#mref-seticon">NSD_SetIcon</a></li>
<li><a href="#mref-seticonfrominstaller">NSD_SetIconFromInstaller</a></li>
<li><a href="#mref-clearimage">NSD_ClearImage</a></li>
<li><a href="#mref-clearicon">NSD_ClearIcon</a></li>
<li><a href="#mref-freeimage">NSD_FreeImage</a></li>
<li><a href="#mref-freeicon">NSD_FreeIcon</a></li>
</ul>
</li>
<li><a href="#faq">FAQ</a></li>
</ul>

<h2><a name="intro"></a>Introduction</h2>

<p>nsDialogs allows creation of custom pages in the installer. On top of the built-in pages, nsDialogs can create pages with any type of controls in any order and arrangement. It can create everything from a simple page with one label to form which reacts to user's actions. <a href="../Modern UI 2/Readme.html">Modern UI 2</a>, for example, uses nsDialogs to create the welcome and finish pages.</p>

<p>nsDialogs is a new NSIS plug-in, introduced in version 2.29 as a replacement for <a href="../InstallOptions/Readme.html">InstallOptions</a>. nsDialogs doesn't use INI files, so it's way faster than InstallOptions. Integration with the script is tighter and more natural - creating controls is done using plug-in functions and notification is done by directly calling a function in the script. Unlike InstallOptions, there isn't a predefined set of available control type and by providing a lower level access to Windows API, every type of control can be created and pages can be more customizable.</p>

<p>The same thing that makes nsDialogs more flexible can also make it more complicated for users with no knowledge of Win32 API. This is solved by creating a library of predefined functions, defined in script, that allow creation and handling of controls. This way, novices get easy access to the flexibility, while advanced users still get access to the core functionality by modifying the library or simply avoid using it.</p>

<h2><a name="step"></a>Step-by-Step Tutorial</h2>

<h3><a name="step-basic"></a>Basic Script</h3>

<p>Before using nsDialogs, lets first create a basic script as our skeleton.</p>

<blockquote><pre>Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Page instfiles

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<h3><a name="step-page"></a>Custom Page</h3>

<p>Next, we'll add a custom page where we can use nsDialogs. nsDialogs cannot be used in sections or any other function but a custom page's function.</p>

<blockquote><pre>Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

<b>Page custom nsDialogsPage</b>
Page instfiles

<b>Function nsDialogsPage
FunctionEnd</b>

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<h3><a name="step-create"></a>Creating Page</h3>

<p>Now that the foundations are laid, it's time to use nsDialogs. The first call must always be to nsDialogs::Create. It will create a new dialog in the page and return its <i>HWND</i> on the stack. The result must be popped from the stack to prevent stack corruption. If the result is <i>error</i>, the dialog couldn't be created.</p>

<p>nsDialogs::Create accepts one parameter. It has a very specific function, but to keep things simple for this tutorial, it must always be 1018.</p>

<p><i>HWND</i> is a number that uniquely identifies the dialog and can be used with SendMessage, SetCtlColors and Win32 API.</p>

<blockquote><pre><b>!include LogicLib.nsh</b>

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

<b>Var Dialog</b>

Page custom nsDialogsPage
Page instfiles

Function nsDialogsPage
<b>
	nsDialogs::Create 1018
	Pop $Dialog

	${If} $Dialog == error
		Abort
	${EndIf}
</b>
FunctionEnd

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<h3><a name="step-show"></a>Showing Page</h3>

<p>Now that the page is created, it's time to show it. This is done with nsDialogs::Show. This function will not return until the user clicks Next, Back or Cancel.</p>

<blockquote><pre>!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Var Dialog

Page custom nsDialogsPage
Page instfiles

Function nsDialogsPage
	nsDialogs::Create 1018
	Pop $Dialog

	${If} $Dialog == error
		Abort
	${EndIf}
<b>
	nsDialogs::Show
</b>
FunctionEnd

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<h3><a name="step-add"></a>Adding Controls</h3>

<p>Compiling the last script and running it results in an empty page which is not very useful. So now we'll add some controls to it to. To do so, we'll use <a href="#mref-create">${NSD_Create*}</a> macros from nsDialogs.nsh. Each of those macros takes 5 parameters - x, y, width, height and text. Each macro also returns one value on the stack, which is the new control's HWND. Like the dialogs HWND, it must be popped from the stack and saved.</p>

<p>Each of the measurements that the macros take can use one of three unit types - pixels, dialog units or percentage of the dialog's size. It can also be negative to indicate it should be measured from the end. To use dialog units, the measurement must be suffixed with the letter <i>u</i>. To use percentage, the measurement must be suffixed with the percentage sign - <i>%</i>. Any other suffix, or no suffix, means pixels.</p>

<p>Dialog units allow creation of dialogs that scale well when different fonts or DPI is used. Its size in pixels is determined on runtime based on the font and the DPI. For example, standard pages in the classic NSIS user interface are 266 dialog units wide and 130 dialog units high. Pages in Modern UI are 300 dialogs units wide and 140 dialog units high. In different resolutions, using different fonts or DPI settings, the dialogs will always have the same size in dialog units, but different size in pixels.</p>

<blockquote><pre><b>!include nsDialogs.nsh</b>
!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Var Dialog
<b>Var Label
Var Text</b>

Page custom nsDialogsPage
Page instfiles

Function nsDialogsPage

	nsDialogs::Create 1018
	Pop $Dialog

	${If} $Dialog == error
		Abort
	${EndIf}
<b>
	${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
	Pop $Label

	${NSD_CreateText} 0 13u 100% -13u "Type something here..."
	Pop $Text
</b>
	nsDialogs::Show

FunctionEnd

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<p>Available control types that can be created with <a href="#mref-create">${NSD_Create*}</a> are:</p>

<ul>
<li>HLine</li>
<li>VLine</li>
<li>Label</li>
<li>Icon</li>
<li>Bitmap</li>
<li>BrowseButton</li>
<li>Link</li>
<li>Button</li>
<li>GroupBox</li>
<li>CheckBox</li>
<li>RadioButton</li>
<li>Text</li>
<li>Password</li>
<li>Number</li>
<li>FileRequest</li>
<li>DirRequest</li>
<li>ComboBox</li>
<li>DropList</li>
<li>ListBox</li>
<li>ProgressBar</li>
</ul>

<h3><a name="step-state"></a>Control State</h3>

<p>Now that we have some controls that the user can interact with, it's time to see what the user actually does with them. For that, we'll first add a <i>leave callback</i> function to our page. In that function, we'll query the state of the text control we've created and display it to the user. To do so, we'll use the <a href="#mref-gettext">${NSD_GetText}</a> macro. Use the <a href="#mref-getstate">${NSD_GetState}</a> macro for RadioButton and CheckBox controls.</p>

<p>Note that not all controls support <a href="#mref-gettext">${NSD_GetText}</a> and some require special handling with specific messages defined in WinMessages.nsh. For example, the ListBox control requires usage of <i>LB_GETCURSEL</i> and <i>LB_GETTEXT</i>. With time, the library of macros in nsDialogs.nsh will fill with more and more macros that'll handle more cases like this.</p>

<blockquote><pre>!include nsDialogs.nsh
!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Var Dialog
Var Label
Var Text

Page custom nsDialogsPage <b>nsDialogsPageLeave</b>
Page instfiles

Function nsDialogsPage

	nsDialogs::Create 1018
	Pop $Dialog

	${If} $Dialog == error
		Abort
	${EndIf}

	${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
	Pop $Label

	${NSD_CreateText} 0 13u 100% -13u "Type something here..."
	Pop $Text

	nsDialogs::Show

FunctionEnd

<b>Function nsDialogsPageLeave

	${NSD_GetText} $Text $0
	MessageBox MB_OK "You typed:$\n$\n$0"

FunctionEnd</b>

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<h3><a name="step-notify"></a>Real-time Notification</h3>

<p>One of the more exciting new features of nsDialogs is callback function notification of changes to the dialog. nsDialogs can call a function defined in a script in response to a user action such as changing of a text field or click of a button. To make nsDialogs notify us of events, we'll use <a href="#mref-onclick">${NSD_OnClick}</a> and <a href="#mref-onchange">${NSD_OnChange}</a>. Not every control supports both of the events. For example, there is nothing to notify about label changes, only clicks.</p>

<p>When the callback function is called, the control's HWND will be waiting on the stack and must be popped to prevent stack corruption. In this simple example, this is not so useful. But in case of a bigger script where several controls are associated with the same callback function, the HWND can shed some light on which control originated the event.</p>

<p>The new example will respond to the user type <i>hello</i> in the text box.</p>

<blockquote><pre>!include nsDialogs.nsh
!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Var Dialog
Var Label
Var Text

Page custom nsDialogsPage nsDialogsPageLeave
Page instfiles

Function nsDialogsPage

	nsDialogs::Create 1018
	Pop $Dialog

	${If} $Dialog == error
		Abort
	${EndIf}

	${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
	Pop $Label

	${NSD_CreateText} 0 13u 100% -13u "Type something here..."
	Pop $Text
	<b>${NSD_OnChange} $Text nsDialogsPageTextChange</b>

	nsDialogs::Show

FunctionEnd

Function nsDialogsPageLeave

	${NSD_GetText} $Text $0
	MessageBox MB_OK "You typed:$\n$\n$0"

FunctionEnd

<b>Function nsDialogsPageTextChange

	Pop $1 # $1 == $ Text

	${NSD_GetText} $Text $0

	${If} $0 == "hello"

		MessageBox MB_OK "right back at ya!"

	${EndIf}

FunctionEnd</b>

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<h3><a name="step-memory"></a>Memory</h3>

<p>So far we have a page that has some basic input controls. But what happens when the user goes to the next page and comes back? With the current code, the user's input will not be remembered. To remember, we'll use the already present leave callback function to store the user's choice in variables and pass these values when creating the controls the next time. For a better example, we'll also add a checkbox to the page and use <a href="#mref-getstate">${NSD_GetState}</a> and <a href="#mref-setstate">${NSD_SetState}</a> to get and set its state.</p>

<p>For clarity, we'll remove some of the notifications from the previous step.</p>

<blockquote><pre>!include nsDialogs.nsh
!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Var Dialog
Var Label
Var Text
<b>Var Text_State
Var Checkbox
Var Checkbox_State</b>

Page custom nsDialogsPage nsDialogsPageLeave
<b>Page license</b>
Page instfiles

<b>Function .onInit

	StrCpy $Text_State "Type something here..."

FunctionEnd</b>

Function nsDialogsPage

	nsDialogs::Create 1018
	Pop $Dialog

	${If} $Dialog == error
		Abort
	${EndIf}

	${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
	Pop $Label

	${NSD_CreateText} 0 13u 100% <b>12u $Text_State</b>
	Pop $Text

	<b>${NSD_CreateCheckbox} 0 30u 100% 10u "&amp;Something"
	Pop $Checkbox

	${If} $Checkbox_State == ${BST_CHECKED}
		${NSD_Check} $Checkbox
	${EndIf}

	# alternative for the above ${If}:
	#${NSD_SetState} $Checkbox_State</b>

	nsDialogs::Show

FunctionEnd

Function nsDialogsPageLeave

	${NSD_GetText} $Text <b>$Text_State</b>
	<b>${NSD_GetState} $Checkbox $Checkbox_State</b>

FunctionEnd

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<h2><a name="ref"></a>Function Reference</h2>

<h3><a name="ref-create"></a>Create</h3>

<p><code>nsDialogs::Create <i>rect</i></code></p>

<p>Creates a new dialog. <i>rect</i> specific the identifier of the control whose location will be mimiced. This should usually be 1018, which is control mimiced for creation of built-in pages. The Modern UI also has control 1040 for the welcome and the finish page.</p>

<p>Returns the new dialog's HWND on the stack or <i>error</i>.</p>

<h3><a name="ref-createcontrol"></a>CreateControl</h3>

<p><code>nsDialogs::CreateControl <i>class</i> <i>style</i> <i>extended_style</i> <i>x</i> <i>y</i> <i>width</i> <i>height</i> <i>text</i></code></p>

<p>Create a new control in the current dialog. A dialog must exist for this to work, so nsDialogs::Create must be called prior to this function.</p>

<p>Returns the new dialog's HWND on the stack or <i>error</i>.</p>

<h3><a name="ref-show"></a>Show</h3>

<p><code>nsDialogs::Show</code></p>

<p>Displays the page. Call this once finished with nsDialogs::Create, nsDialogs::CreateControl and the rest.</p>

<p>Returns nothing.</p>

<h3><a name="ref-selectfiledialog"></a>SelectFileDialog</h3>

<p><code>nsDialogs::SelectFileDialog <i>mode</i> <i>initial_selection</i> <i>filter</i></code></p>

<p>Displays a file selection dialog to the user. If <i>mode</i> is set to <i>save</i>, displays a file save dialog. If <i>mode</i> is set to <i>open</i>, displays a file open dialog. <i>filter</i> is a list of available file filters separated by pipes. If an empty string is passed, the default is used - <i>All Files|*.*</i>.</p>

<p><i>initial_selection</i> can be used to provide the user with a default file to look for and/or a default folder to look in. If <i>initial_selection</i> is empty no default filename will be provided for the user and the dialog will start in the current working directory. If <i>initial_selection</i> specifies just a filename, for example "test.exe", the dialog will be set up to look for a file called test.exe in the current working directory. If <i>initial_selection</i> specifies just a directory, for example "C:\Program Files", the dialog starts in the provided directory with no file name provided. If <i>initial_selection</i> specifies a directory and a filename, for example "C:\Windows\System32\calc.exe", the dialog will be set up to look for a file called calc.exe in the directory C:\Windows\System32.</p>

<p>Returns the selected file on the stack or an empty string if the user canceled the operation.</p>

<h3><a name="ref-selectfolderdialog"></a>SelectFolderDialog</h3>

<p><code>nsDialogs::SelectFolderDialog <i>title</i> <i>initial_selection</i></code></p>

<p>Displays a directory selection dialog to the user.</p>

<p>Returns the selected directory on the stack or "error" in case the user canceled the operation or an error occured.</p>

<h3><a name="ref-setrtl"></a>SetRTL</h3>

<p><code>nsDialogs::SetRTL <i>rtl_setting</i></code></p>

<p>Sets right-to-left mode on or off. If <i>rtl_setting</i> is 0, it's set to off. If <i>rtl_setting</i> is 1, it's set to on. This function must be called before any calls to nsDialogs::CreateControl.</p>

<p>Returns nothing.</p>

<h3><a name="ref-getuserdata"></a>GetUserData</h3>

<p><code>nsDialogs::GetUserData <i>control_HWND</i></code></p>

<p>Returns user data associated with the control on the stack.  Use nsDialogs::SetUserData to set this data.</p>

<h3><a name="ref-setuserdata"></a>SetUserData</h3>

<p><code>nsDialogs::SetUserData <i>control_HWND</i> <i>data</i></code></p>

<p>Associates <i>data</i> with the control. Use nsDialogs::GetUserData to get this data.</p>

<p>Returns nothing.</p>

<h3><a name="ref-onback"></a>OnBack</h3>

<p><code>nsDialogs::OnBack <i>function_address</i></code></p>

<p>Sets the callback function for the Back button. This function will be called when the user clicks the back button. Call Abort in this function to prevent the user from going back to the last page.</p>

<p>Use GetFunctionAddress to get the address of the desired callback function.</p>

<p>Returns nothing.</p>

<h3><a name="ref-onchange"></a>OnChange</h3>

<p><code>nsDialogs::OnChange <i>control_HWND</i> <i>function_address</i></code></p>

<p>Sets a change notification callback function for the given control. Whenever the control changes, the function will be called and the control's HWND will be waiting on its stack.</p>

<p>Use GetFunctionAddress to get the address of the desired callback function.</p>

<p>Returns nothing.</p>

<h3><a name="ref-onclick"></a>OnClick</h3>

<p><code>nsDialogs::OnClick <i>control_HWND</i> <i>function_address</i></code></p>

<p>Sets a click notification callback function for the given control. Whenever the control is clicked, the function will be called and the control's HWND will be waiting on its stack.</p>

<p>Use GetFunctionAddress to get the address of the desired callback function.</p>

<p>Returns nothing.</p>

<h3><a name="ref-onnotify"></a>OnNotify</h3>

<p><code>nsDialogs::OnNotify <i>control_HWND</i> <i>function_address</i></code></p>

<p>Sets a notification callback function for the given control. Whenever the control receives the WM_NOTIFY message, the function will be called and the control's HWND, notification code and a pointer to the MNHDR structure will be waiting on its stack.</p>

<p>Use GetFunctionAddress to get the address of the desired callback function.</p>

<p>Returns nothing.</p>

<h3><a name="ref-createtimer"></a>CreateTimer</h3>

<p><code>nsDialogs::CreateTimer <i>function_address</i> <i>timer_interval</i></code></p>

<p>Sets a timer that'd call the callback function for the given control every in a constant interval. Interval times are specified in milliseconds.</p>

<p>Use GetFunctionAddress to get the address of the desired callback function.</p>

<p>Returns nothing.</p>

<h3><a name="ref-killtimer"></a>KillTimer</h3>

<p><code>nsDialogs::KillTimer <i>function_address</i></code></p>

<p>Kills a previously set timer.</p>

<p>Use GetFunctionAddress to get the address of the desired callback function.</p>

<p>Returns nothing.</p>

<h2><a name="mref"></a>Macro Reference</h2>

<p>nsDialogs.nsh contains a lot of macros that can make nsDialogs usage a lot easier. Below is a description of each of those macros including purpose, syntax, input and output.</p>

<h3><a name="mref-create"></a>NSD_Create*</h3>

<p><code>${NSD_Create*} <i>x</i> <i>y</i> <i>width</i> <i>height</i> <i>text</i></code></p>

<p>Create a new control in the current dialog. A dialog must exist for this to work, so nsDialogs::Create must be called prior to this function.</p>

<p>Available variants:</p>

<ul>
<li>${NSD_CreateHLine}</li>
<li>${NSD_CreateVLine}</li>
<li>${NSD_CreateLabel}</li>
<li>${NSD_CreateIcon}</li>
<li>${NSD_CreateBitmap}</li>
<li>${NSD_CreateBrowseButton}</li>
<li>${NSD_CreateLink}</li>
<li>${NSD_CreateButton}</li>
<li>${NSD_CreateGroupBox}</li>
<li>${NSD_CreateCheckBox}</li>
<li>${NSD_CreateRadioButton}</li>
<li>${NSD_CreateText}</li>
<li>${NSD_CreatePassword}</li>
<li>${NSD_CreateNumber}</li>
<li>${NSD_CreateFileRequest}</li>
<li>${NSD_CreateDirRequest}</li>
<li>${NSD_CreateComboBox}</li>
<li>${NSD_CreateDropList}</li>
<li>${NSD_CreateListBox}</li>
<li>${NSD_CreateProgressBar}</li>
</ul>

<p>Returns the new dialog's HWND on the stack or error.</p>

<h3><a name="mref-onback"></a>NSD_OnBack</h3>

<p><code>${NSD_OnBack} <i>function_address</i></code></p>

<p>See <a href="#ref-onback">OnBack</a> for more details.</p>

<p></p>

<h3><a name="mref-onchange"></a>NSD_OnChange</h3>

<p><code>${NSD_OnChange} <i>control_HWND</i> <i>function_address</i></code></p>

<p>See <a href="#ref-onchange">OnChange</a> for more details.</p>

<p>See <a href="#step-notify">Real-time Notification</a> for usage example.</p>

<h3><a name="mref-onclick"></a>NSD_OnClick</h3>

<p><code>${NSD_OnClick} <i>control_HWND</i> <i>function_address</i></code></p>

<p>See <a href="#ref-onclick">OnClick</a> for more details.</p>

<h3><a name="mref-onnotify"></a>NSD_OnNotify</h3>

<p><code>${NSD_OnNotify} <i>control_HWND</i> <i>function_address</i></code></p>

<p>See <a href="#ref-onnotify">OnNotify</a> for more details.</p>

<h3><a name="mref-createtimer"></a>NSD_CreateTimer</h3>

<p><code>${NSD_CreateTimer} <i>function_address</i> <i>timer_interval</i></code></p>

<p>See <a href="#ref-createtimer">CreateTimer</a> for more details.</p>

<h3><a name="mref-killtimer"></a>NSD_KillTimer</h3>

<p><code>${NSD_KillTimer} <i>function_address</i></code></p>

<p>See <a href="#ref-killtimer">KillTimer</a> for more details.</p>

<h3><a name="mref-addstyle"></a>NSD_AddStyle</h3>

<p><code>${NSD_AddStyle} <i>control_HWND</i> <i>style</i></code></p>

<p>Adds one or more window style to a control. Multiple styles should be separated with pipes `|'.</p>

<p>See MSDN for style description.</p>

<h3><a name="mref-addexstyle"></a>NSD_AddExStyle</h3>

<p><code>${NSD_AddExStyle} <i>control_HWND</i> <i>style</i></code></p>

<p>Adds one or more extended window style to a control. Multiple styles should be separated with pipes `|'.</p>

<p>See MSDN for style description.</p>

<h3><a name="mref-gettext"></a>NSD_GetText</h3>

<p><code>${NSD_GetText} <i>control_HWND</i> <i>output_variable</i></code></p>

<p>Retrieves the text of a control and stores it into <i>output_variable</i>. Especially useful for textual controls.</p>

<p>See <a href="#step-state">Control State</a> for usage example.</p>

<h3><a name="mref-settext"></a>NSD_SetText</h3>

<p><code>${NSD_SetText} <i>control_HWND</i> <i>text</i></code></p>

<p>Sets the text of a control.</p>

<h3><a name="mref-settextlimit"></a>NSD_SetTextLimit</h3>

<p><code>${NSD_SetTextLimit} <i>control_HWND</i> <i>limit</i></code></p>

<p>Sets input size limit for a text control.</p>

<h3><a name="mref-getstate"></a>NSD_GetState</h3>

<p><code>${NSD_GetState} <i>control_HWND</i> <i>output_variable</i></code></p>

<p>Retrieves the state of a check box or a radio button control. Possible outputs are ${BST_CHECKED} and ${BST_UNCHECKED}.</p>

<p>See <a href="#step-memory">Memory</a> for usage example.</p>

<h3><a name="mref-setstate"></a>NSD_SetState</h3>

<p><code>${NSD_SetState} <i>control_HWND</i> <i>state</i></code></p>

<p>Sets the state of a check box or a radio button control. Possible values for <i>state</i> are ${BST_CHECKED} and ${BST_UNCHECKED}.</p>

<p>See <a href="#step-memory">Memory</a> for usage example.</p>

<h3><a name="mref-check"></a>NSD_Check</h3>

<p><code>${NSD_Check} <i>control_HWND</i></code></p>

<p>Checks a check box or a radio button control. Same as calling ${NSD_SetState} with ${BST_CHECKED}.</p>

<h3><a name="mref-uncheck"></a>NSD_Uncheck</h3>

<p><code>${NSD_Uncheck} <i>control_HWND</i></code></p>

<p>Unchecks a check box or a radio button control. Same as calling ${NSD_SetState} with ${BST_UNCHECKED}.</p>

<p>See <a href="#step-memory">Memory</a> for usage example.</p>

<h3><a name="mref-cbaddstring"></a>NSD_CB_AddString</h3>

<p><code>${NSD_CB_AddString} <i>combo_HWND</i> <i>string</i></code></p>

<p>Adds a string to a combo box.</p>

<h3><a name="mref-cbselectstring"></a>NSD_CB_SelectString</h3>

<p><code>${NSD_CB_SelectString} <i>combo_HWND</i> <i>string</i></code></p>

<p>Selects a string in a combo box.</p>

<h3><a name="mref-lbaddstring"></a>NSD_LB_AddString</h3>

<p><code>${NSD_LB_AddString} <i>listbox_HWND</i> <i>string</i></code></p>

<p>Adds a string to a list box.</p>

<h3><a name="mref-lbdelstring"></a>NSD_LB_DelString</h3>

<p><code>${NSD_LB_DelString} <i>listbox_HWND</i> <i>string</i></code></p>

<p>Deletes a string from a list box.</p>

<h3><a name="mref-lbcleqar">NSD_LB_Clear</a></h3>

<p><code>${NSD_LB_Clear} <i>listbox_HWND</i></code></p>

<p>Deletes all strings from a list box.</p>

<h3><a name="mref-lbgetcount">NSD_LB_GetCount</a></h3>

<p><code>${NSD_LB_GetCount} <i>listbox_HWND</i> <i>output_variable</i></code></p>

<p>Retrieves the number of strings from a list box.</p>

<h3><a name="mref-lbselectstring"></a>NSD_LB_SelectString</h3>

<p><code>${NSD_LB_SelectString} <i>listbox_HWND</i> <i>string</i></code></p>

<p>Selects a string in a list box.</p>

<h3><a name="mref-lbgetselection">NSD_LB_GetSelection</a></h3>

<p><code>${NSD_LB_GetSelection} <i>listbox_HWND</i> <i>output_variable</i></code></p>

<p>Retrieves the selected stringed from a list box. Returns an empty string if no string is selected.</p>

<h3><a name="mref-setfocus"></a>NSD_SetFocus</h3>

<p><code>${NSD_SetFocus} <i>control_HWND</i></code></p>

<p>Sets focus to a control.</p>

<h3><a name="mref-setimage"></a>NSD_SetImage</h3>

<p><code>${NSD_SetImage} <i>control_HWND</i> <i>image_path</i> <i>output_variable</i></code></p>

<p>Loads a bitmap from <i>image_path</i> and displays it on <i>control_HWND</i> created by <a href="#mref-create">${NSD_CreateBitmap}</a>. The image handle is stored in <i>output_variable</i> and should be freed using <a href="#mref-freeimage">${NSD_FreeImage}</a> once no longer necessary.</p>

<p>The image must be extracted to the user's computer prior to calling this macro. A good place to extract images is $PLUGINSDIR.</p>

<blockquote><pre>!include nsDialogs.nsh

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Page custom nsDialogsImage
Page instfiles

Var Dialog
Var Image
Var ImageHandle

Function .onInit

	InitPluginsDir
	File /oname=$PLUGINSDIR\image.bmp "${NSISDIR}\Contrib\Graphics\Header\nsis-r.bmp"

FunctionEnd

Function nsDialogsImage

	nsDialogs::Create 1018
	Pop $Dialog

	${If} $Dialog == error
		Abort
	${EndIf}

	${NSD_CreateBitmap} 0 0 100% 100% ""
	Pop $Image
	${NSD_SetImage} $Image $PLUGINSDIR\image.bmp $ImageHandle

	nsDialogs::Show

	${NSD_FreeImage} $ImageHandle

FunctionEnd

Section
SectionEnd</pre></blockquote>

<h3><a name="mref-setsimage"></a>NSD_SetStretchedImage</h3>

<p><code>${NSD_SetStretchedImage} <i>control_HWND</i> <i>image_path</i> <i>output_variable</i></code></p>

<p>Loads and displays a bitmap just like <a href="#mref-setimage">${NSD_SetImage}</a>, but stretched the image to fit the control.</p>

<h3><a name="mref-seticon"></a>NSD_SetIcon</h3>

<p><code>${NSD_SetIcon} <i>control_HWND</i> <i>image_path</i> <i>output_variable</i></code></p>

<p>Same as <a href="#mref-setimage">${NSD_SetImage}</a>, but used for loading and setting an icon in a control created by <a href="#mref-create">${NSD_CreateIcon}</a>. The image handle is stored in <i>output_variable</i> and should be freed using <a href="#mref-freeicon">${NSD_FreeIcon}</a> once no longer necessary.</p>

<h3><a name="mref-seticonfrominstaller"></a>NSD_SetIconFromInstaller</h3>

<p><code>${NSD_SetIconFromInstaller} <i>control_HWND</i> <i>output_variable</i></code></p>

<p>Loads the icon used in the isntaller and displays it on <i>control_HWND</i> created by <a href="#mref-create">${NSD_CreateIcon}</a>. The image handle is stored in <i>output_variable</i> and should be freed using <a href="#mref-freeicon">${NSD_FreeIcon}</a> once no longer necessary.</p>

<h3><a name="mref-clearimage"></a>NSD_ClearImage</h3>

<p><code>${NSD_ClearImage} <i>control_HWND</i></code></p>

<p>Clears an image from a control.</p>

<h3><a name="mref-clearicon"></a>NSD_ClearIcon</h3>

<p><code>${NSD_ClearIcon} <i>control_HWND</i></code></p>

<p>Clears an icon from a control.</p>

<h3><a name="mref-freeimage"></a>NSD_FreeImage</h3>

<p><code>${NSD_FreeImage} <i>image_handle</i></code></p>

<p>Frees an image handle previously loaded with <a href="#mref-setimage">${NSD_SetImage}</a> or <a href="#mref-setsimage">${NSD_SetStretchedImage}</a>.</p>

<h3><a name="mref-freeicon"></a>NSD_FreeIcon</h3>

<p><code>${NSD_FreeIcon} <i>icon_handle</i></code></p>

<p>Frees an icon handle previously loaded with <a href="#mref-seticon">${NSD_SetIcon}</a> or <a href="#mref-seticonfrominstaller">${NSD_SetIconFromInstaller}</a>.</p>


<h2><a name="faq"></a>FAQ</h2>

<div>

<ul>

<li>
<b>Q:</b> Can nsDialogs handle InstallOptions INI files?
<blockquote>
<p><b>A:</b> nsDialogs.nsh contains a function called <i>CreateDialogFromINI</i> that can create nsDialogs' dialog from an INI file. It can handle every type of control InstallOptions supports, but doesn't handle the flags or notification yet. <i>Examples\nsDialogs\InstallOptions.nsi</i> shows a usage example of this function.</p><p>In the future there'll also be a function that creates the script itself.
</blockquote>
</li>

</ul>

</div>

</body>
</html>
